#!/bin/bash

# 定义期望的横幅文本
EXPECTED_BANNER="Authorized uses only. All activity may be monitored and reported."

# 检查/etc/issue是否存在
if [ ! -f "/etc/issue" ]; then
    echo "[-] /etc/issue 文件不存在"
    exit 1
fi

# 检查文件内容是否符合要求
if [ -s "/etc/issue" ]; then
    current_content=$(cat /etc/issue | tr -d '\n\r' | sed 's/[[:space:]]*$//')
    if [ "$current_content" = "$EXPECTED_BANNER" ]; then
        echo "[+] /etc/issue 内容符合要求"
        CONTENT_OK=1
    else
        echo "[-] /etc/issue 内容不符合要求"
        echo "    当前内容: '$current_content'"
        echo "    期望内容: '$EXPECTED_BANNER'"
        CONTENT_OK=0
    fi
else
    echo "[-] /etc/issue 文件为空"
    CONTENT_OK=0
fi

if [ $CONTENT_OK -eq 0 ]; then
    exit 1
fi

